package com.kd.spring.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;


//后处理Bean，需要在配置文件里面配置，不需要配置bean的Id，spring容器会自动调用
public class MyBeanProcessor implements BeanPostProcessor {

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName)
			throws BeansException {
		System.out.println("第八步：后处理bean after 初始化……");
		if(beanName.equals("beanLife")){
			System.out.println("beanLife结束处理");
		}
		return bean;
	}

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName)
			throws BeansException {
		System.out.println("第五步：后处理bean after 初始化……");
		if(beanName.equals("beanLife")){
			System.out.println("beanLife开始处理");
		}
		return bean;
	}

	
}
